/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.PWM;

/**
 *
 * @author Mentors  Carl Burger
 */
public class ShapeIndicatorLEDs {

    // digital outputs for the shape indicator LEDs

//    private static DigitalOutput triangleLEDs;
//    private static DigitalOutput circleLEDs;
//    private static DigitalOutput squareLEDs;

    // PWM controllers for the shape indicator LEDs

    private static PWM triangleLEDs;
    private static PWM circleLEDs;
    private static PWM squareLEDs;

    private static ShapeIndicatorLEDs m_instance = null;

    /**
     *  Get an instance of the ShapeIndicatorLEDs
     */

    public static ShapeIndicatorLEDs getInstance() {

        if (m_instance == null) {
            m_instance = new ShapeIndicatorLEDs();
        }
        
        return m_instance;
    }


    private ShapeIndicatorLEDs () {

        // create the digital output objects to write to the shape indicator LEDs

//        triangleLEDs = new DigitalOutput(triangleChannel);
//        circleLEDs   = new DigitalOutput(circleChannel);
//        squareLEDs   = new DigitalOutput(squareChannel);

        // create the PWM objects to write to the shape indicator LEDs

        triangleLEDs = new PWM(LogomotionRobot.ktriangleLED);
        circleLEDs   = new PWM(LogomotionRobot.kcircleLED);
        squareLEDs   = new PWM(LogomotionRobot.ksquareLED);

        set(false, false, false);
        // nothing to do
    }

    /**
     * called from DriverStation708
     */
    //why don't we try this!?!?
//    public void set(byte lights){
//      boolean extractedBoolean = (lights & 0x07) > 0;       
//      
//    }
    public void set (boolean triangle, boolean circle, boolean square) {
        
        int rawvalue;
                
        rawvalue = triangle ? 128: 0;
        triangleLEDs.setRaw(rawvalue);

        rawvalue = circle ? 254: 0;     // make as bright as possible
        circleLEDs.setRaw(rawvalue);

        rawvalue = square ? 128: 0;
        squareLEDs.setRaw(rawvalue);

    }

}